home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 7.0 KB | 250 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWBmpShp.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWBMPSHP_H
- #include "FWBmpShp.h"
- #endif
-
- #ifndef SLGRGLOB_H
- #include "SLGrGlob.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifndef SLRENDER_H
- #include "SLRender.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWDEBUG_H
- #include "FWDebug.h"
- #endif
-
- //========================================================================================
- // File scope definitions
- //========================================================================================
-
- #if defined(__MWERKS__) && GENERATING68K
- // A hack to work around a bug
- #pragma import list somGetGlobalEnvironment
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphxshape
- #endif
-
- //========================================================================================
- // CLASS FW_CBitmapShape
- //========================================================================================
-
- FW_DEFINE_CLASS_M1(FW_CBitmapShape, FW_CBoundedShape)
- FW_DEFINE_AUTO(FW_CBitmapShape)
-
- // This class is archivable, but we provide the archiving implementation in a separate
- // translation unit in order to enable deadstripping of the archiving-related code
- // in parts that do not use archiving with this class.
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::FW_CBitmapShape
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape::FW_CBitmapShape(const FW_CBitmapShape& other) :
- FW_CBoundedShape(other),
- fSrcRect(other.fSrcRect),
- fBitmap(other.fBitmap)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::FW_CBitmapShape
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape::FW_CBitmapShape(FW_CBitmap bitmap, const FW_CRect& dstRect) :
- FW_CBoundedShape(dstRect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
- fBitmap(bitmap)
- {
- short width, height,rowBytes, pixelSize;
-
- fBitmap.GetBitmapInfo(width, height, rowBytes, pixelSize);
- fSrcRect.SetInt(0, 0, width, height);
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::FW_CBitmapShape
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape::FW_CBitmapShape(FW_CBitmap bitmap, const FW_CRect& srcRect, const FW_CRect& dstRect) :
- FW_CBoundedShape(dstRect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
- fSrcRect(srcRect),
- fBitmap(bitmap)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::FW_CBitmapShape
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape::FW_CBitmapShape(FW_CReadableStream& stream) :
- FW_CBoundedShape(stream)
- {
- stream.Read(&fSrcRect, 4);
- stream >> fBitmap;
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::~FW_CBitmapShape
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape::~FW_CBitmapShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape& FW_CBitmapShape::operator=(const FW_CBitmapShape& other)
- {
- if (this != &other)
- {
- FW_CBoundedShape::operator=(other);
-
- fBitmap = other.fBitmap;
- fSrcRect = other.fSrcRect;
- }
-
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::Copy
- //----------------------------------------------------------------------------------------
-
- FW_CShape* FW_CBitmapShape::Copy() const
- {
- return FW_NEW(FW_CBitmapShape, (*this));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::Render
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::Render(FW_CGraphicContext& gc) const
- {
- FW_PrivRenderBitmap(gc.GetEnvironment(),
- gc,
- fBitmap,
- fSrcRect,
- fRect,
- GetRenderVerb(),
- fInk);
- FW_FailOnEvError(gc.GetEnvironment());
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::RenderBitmap
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::RenderBitmap(FW_CGraphicContext& gc,
- FW_CBitmap bitmap,
- const FW_CRect& dstRect,
- const FW_CInk& ink)
- {
- FW_CRect srcRect;
- bitmap.GetBitmapBounds(srcRect);
-
- FW_PrivRenderBitmap(gc.GetEnvironment(),
- gc,
- bitmap,
- srcRect,
- dstRect,
- FW_kFill,
- ink);
- FW_FailOnEvError(gc.GetEnvironment());
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::RenderBitmap
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::RenderBitmap(FW_CGraphicContext& gc,
- FW_CBitmap bitmap,
- const FW_CRect& srcRect,
- const FW_CRect& dstRect,
- const FW_CInk& ink)
- {
- FW_PrivRenderBitmap(gc.GetEnvironment(),
- gc,
- bitmap,
- srcRect,
- dstRect,
- FW_kFill,
- ink);
- FW_FailOnEvError(gc.GetEnvironment());
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::GetGeometry
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::GetGeometry(FW_CBitmap& bitmap,
- FW_CRect& srcRect,
- FW_CRect& dstRect) const
- {
- bitmap = fBitmap;
- srcRect = fSrcRect;
- dstRect = fRect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::SetGeometry
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::SetGeometry(const FW_CBitmap& bitmap,
- const FW_CRect& srcRect,
- const FW_CRect& dstRect)
- {
- fBitmap = bitmap;
- fSrcRect = srcRect;
- fRect = dstRect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::Flatten(FW_CWritableStream& stream) const
- {
- FW_CBoundedShape::Flatten(stream);
- stream.Write(&fSrcRect, 4);
- Environment* ev = somGetGlobalEnvironment();
- stream << fBitmap;
- }
-
-